# Contributor: nu <llnu@protonmail.ch>
# Maintainer: nu <llnu@protonmail.ch>
pkgname=avro
pkgver=1.11.3
pkgrel=1
pkgdesc="Avro, a data serialization system"
url="https://avro.apache.org/docs/current/api/c/index.html"
# 32-bit: fails tests
arch="all !armhf !armv7 !x86"
depends_dev="
	boost-dev
	jansson-dev
	snappy-dev
	"
makedepends="
	$depends_dev
	cmake
	samurai
	xz-dev
	zlib-dev
	"
license="Apache-2.0"
subpackages="
	$pkgname-dev
	libavro
	libavrocpp
	"
source="https://archive.apache.org/dist/avro/avro-$pkgver/avro-src-$pkgver.tar.gz
	nostatic.patch
	pkgconf.patch
	version-bash.patch
	no-werror-for-c++.patch
	"
builddir="$srcdir"/avro-src-$pkgver/lang

build() {
	export CFLAGS="$CFLAGS -O2 -DNDEBUG -flto=auto"
	export CXXFLAGS="$CXXFLAGS -O2 -DNDEBUG -flto=auto -Wno-cpp"
	cmake -B build-c -G Ninja -S c \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_BUILD_TYPE=None \
		-DTHREADSAFE=ON
	cmake --build build-c

	cmake -B build-c++ -G Ninja -S c++ \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_BUILD_TYPE=None
	cmake --build build-c++
}

check() {
	ctest --test-dir build-c --output-on-failure -j1
	ctest --test-dir build-c++ --output-on-failure -j1
}

package() {
	DESTDIR="$pkgdir" cmake --install build-c++
	DESTDIR="$pkgdir" cmake --install build-c
}

libavro() {
	pkgdesc="$pkgdesc (C library)"

	amove usr/lib/libavro.so.*
}

libavrocpp() {
	pkgdesc="$pkgdesc (C++ library)"

	amove usr/lib/libavrocpp.so.*
}

sha512sums="
c2233a16618dab10253b17f71ab169a242b0b2328d1daceb2d0c0ae64417c81c618100da3518203cc63fa801a514697e7c32ce71926a08d2003a4c12da67a5bd  avro-src-1.11.3.tar.gz
e875a3726507326dd80b59906623015aaab685400e9f9fb30f10a8e7e5713b02804b1b38da41649c1b79586b1db8856f1c659280d951c4e616e707fb970a3726  nostatic.patch
cbd23242847c6e4e299165157205c74e8473be523ad739397a52d47ca2e3f699525e4dc96511f0ce8f13f98b8a2eeaa44a921a9986c6ffe57e3a3828e1376bdf  pkgconf.patch
71153a9a0f8607e48b7cf6fa5e0d70bb11162ec0f1f721dbee7b753f237dbfad1df57c4cd8917a7dd1ef19750bf07e12b04fbfe3fc9cc8bc91a6ef875a7cc778  version-bash.patch
3fe8feaecf5cb43a7153ca6583756bd853454868266bf23cf11316f52dda0a03ae78d0ef8c79799f78df3c5e029806fd5459c58ae7524fdde9ffba4eea8ba088  no-werror-for-c++.patch
"
